<?php
if(!defined('L_ADMOD')) {echo "<meta http-equiv='refresh' content='0; url=/?nma=error&act=403'>";exit;}
include("./inc/bloced.php");

include("admin/$op/menu.php");

if ($item=='newlinks')
{
	$query_add="links.mod_block = '1' and mod_wcps='0'";
	$TitleAdd=_NEWLINKS_;
}
if ($item=='alllinks')
{
	$query_add="links.mod_block = '0' and mod_wcps='0' and mod_ban='0'";
	$TitleAdd=_MYCAT_;
}
if ($item=='wcpslinks')
{
	$query_add="mod_wcps='1' and mod_block='0'";
	$TitleAdd=_CHECKWCPS_;
}
if ($item=='wcpsnewlinks')
{
	$query_add="mod_wcps='1' and mod_block='1'";
	$TitleAdd=_NEWWCPS_;
}
if ($item=='banlist')
{
	$query_add="mod_ban='1'";
	$TitleAdd=_VIEWBAN_;
}

	print '<h4><font color="#000080">'.$TitleAdd.'</font></h4>';

$query_new = mysql_query("SELECT links . * , category.mod_id AS cat_id, 
	category.mod_category AS category_name, 
	category.mod_18 AS mod_18, 
	user.user_name 
	FROM ${wcpref}".$op." links 
	INNER JOIN ${wcpref}".$op."_category category ON links.mod_cat_id = category.mod_id 
	INNER JOIN ${wcpref}user user ON links.mod_user_id=user.id 
	WHERE ".$query_add."");
	

	print '<br><table width="100%" cellpadding="1" cellspacing="1" border="0" align="center">
		<tr class="head">
			<td align="center">'._DAT_.'</td>
			<td align="center">'._WHOADD_.'</td>
			<td align="center">'._SELECTCAT_.'</td>
			<td align="center">'._URL_.'</td>
			<td align="center">'._TYPESHORT_.'</td>
			<td align="center">'._TYPEFULL_.'</td>
			<td colspan="4" align="center">'._FORWCPS_.'</td>
			<td align="center">'._DOIT_.'</td>
		</tr>';
	$d=0;
	while ($result_new=mysql_fetch_array($query_new))
	{
		$d++;$iclass = ($d % 2) ? "even" : "odd";
		extract($result_new);
		
		if ($mod_ban==0)
		{
			$ban_img='<img src="/images/'.$op.'/accept.png" border="0" title="'._ADDTOBAN_.'">';
			$a_ban='<a href="admin.php?op='.$op.'&flag=doit&goto=links&taction=toban&lid='.$mod_id.'&item='.$item.'">';
		}else
		{
			$ban_img='<img src="/images/'.$op.'/cross_octagon_fram.png" border="0" title="'._ADDNOBAN_.'">';
			$a_ban='<a href="admin.php?op='.$op.'&flag=doit&goto=links&taction=outban&lid='.$mod_id.'&item='.$item.'">';
		}
		
		if ($mod_reverse_url!='')
			$reverceUrl='<a href="http://'.$mod_reverse_url.'" target="_blank">(rev)</a>';
		else
			$reverceUrl='';
		if ($mod_block==0)
		{
			$actimage='act.gif';
			$acttitle=_NOACT_;
			$actaction='noactnew';
		}
		elseif($mod_block==1)
		{
			$actimage='noact.gif';
			$acttitle=_ACT_;
			$actaction='actnew';
		}
		$dat=date('d.m.Y', strtotime($mod_dat));
		if($mod_wcps==0)
			$clspan='colspan="5"';
		else
			$clspan='';
		print '<tr class="'.$iclass.'">
			<td align="center">'.$dat.'</td>
			<td align="center">'.$user_name.'</td>
			<td align="center">'.$category_name.'</td>
			<td><a href="http://'.$mod_url.'" target="_blank">'.$mod_name.'</a> '.$reverceUrl.'</td>
			<td>'.$mod_short.'</td>
			<td '.$clspan.'>'.$mod_full.'</td>';
			if ($mod_wcps==1)
			{
				$rduN=CreateDate(date("d.m.Y"), "U");
				$font_end='</font>';
				if ($mod_allow_url=='0000-00-00')
				{
					$payed_url=_NO_;
					$font_beg_url='<font color="#FF0000">';
				}elseif($mod_allow_url!='')
				{
					$payed_url=CreateDate($mod_allow_url, "dmy");
					$rduU=CreateDate($mod_allow_url, "U");
					if ($rduU>=$rduN)
						$font_beg_url='<font color="#008000">';
					else
						$font_beg_url='<font color="#FF0000">';
				}
				
				if ($mod_allow_map=='0000-00-00')
				{
					$payed_map=_NO_;
					$font_beg_map='<font color="#FF0000">';
				}elseif($mod_allow_map!='')
				{
					$payed_map=CreateDate($mod_allow_map, "dmy");
					$rduM=CreateDate($mod_allow_map, "U");
					if ($rduM>=$rduN)
						$font_beg_map='<font color="#008000">';
					else
						$font_beg_map='<font color="#FF0000">';
				}
				
				print '<td align="center" title="'._TDMAP1STAT_.'">'.$mod_map.'</td>
				<td align="center" title="'._TDMAP2STAT_.'">'.$mod_map1.'</td>
				<td align="center">'.$font_beg_url.$payed_url.$font_end.'</td>
				<td align="center">'.$font_beg_map.$payed_map.$font_end.'</td>';
			}
			print'<td align="center" width="77px">';
				
				print '<a href="?op='.$op.'&flag=doit&goto='.$flag.'&taction='.$actaction.'&lid='.$mod_id.'&item='.$item.'" title="'.$acttitle.'"><img src="./images/icon/'.$actimage.'" border="0"></a>
				'.$a_ban.$ban_img.'</a>';
				if ($mod_wcps==0)
					print'<a href="?op='.$op.'&flag=editfrm&goto=editfrm&lid='.$mod_id.'" title="'._EDIT_.'"><img src="./images/buttons/edit.gif" border="0"></a>';
				else
					print'<a href="index.php?nma='.$op.'&fla=edwcpssite&sid='.$mod_id.'" title="'._EDIT_.'"><img src="./images/buttons/edit.gif" border="0"></a>';
				//if ($mod_wcps==0)
					print'<a href="?op='.$op.'&flag=doit&goto=forall&taction=dellink&lid='.$mod_id.'&item='.$item.'" title="'._DELETE_.'"><img src="./images/buttons/del.gif" border="0">';
				//else
				//	print'<a href="?op='.$op.'&flag=delwcps&lid='.$mod_id.'" title="'._DELETE_.'"><img src="./images/buttons/del.gif" border="0">';
			print'</td>
		</tr>';
	}
	print'</table>';

function CreateDate($dat, $mode)
{
	if ($mode=="dmY")
		$NewDat=date('d.m.Y', strtotime($dat)); 
	elseif($mode=="U")
		$NewDat=date(strtotime($dat)); 
	elseif($mode=="dmy")
		$NewDat=date('d.m.y', strtotime($dat)); 
	return $NewDat;
}

?>